package com.mall.business.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.mall.common.annotation.Log;
import com.mall.common.core.controller.BaseController;
import com.mall.common.core.domain.AjaxResult;
import com.mall.common.enums.BusinessType;
import com.mall.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mall.business.domain.TUserSign;
import com.mall.business.service.ITUserSignService;
import com.mall.common.core.page.TableDataInfo;

/**
 * 用户签到Controller
 *
 * @author ruoyi
 * @date 2025-04-06
 */
@RestController
@RequestMapping("/business/usersign" )
public class TUserSignController extends BaseController {
    @Autowired
    private ITUserSignService tUserSignService;

/**
 * 查询用户签到列表
 */
//@RequiresPermissions("business:usersign:list")
@GetMapping("/list" )
    public TableDataInfo list(TUserSign tUserSign) {
        startPage();
        List<TUserSign> list = tUserSignService.selectTUserSignList(tUserSign);
        return getDataTable(list);
    }

    /**
     * 导出用户签到列表
     */
    //@RequiresPermissions("business:usersign:export")
    @Log(title = "用户签到" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, TUserSign tUserSign) {
        List<TUserSign> list = tUserSignService.selectTUserSignList(tUserSign);
        ExcelUtil<TUserSign> util = new ExcelUtil<TUserSign>(TUserSign. class);
        util.exportExcel(response, list, "用户签到数据" );
    }

    /**
     * 获取用户签到详细信息
     */
    //@RequiresPermissions("business:usersign:query")
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) String id) {
        return AjaxResult.success(tUserSignService.getById(id));
    }

    /**
     * 新增用户签到
     */
    //@RequiresPermissions("business:usersign:add")
    @Log(title = "用户签到" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TUserSign tUserSign) {
        return toAjax(tUserSignService.save(tUserSign));
    }

    /**
     * 修改用户签到
     */
    //@RequiresPermissions("business:usersign:edit")
    @Log(title = "用户签到" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TUserSign tUserSign) {
        return toAjax(tUserSignService.updateById(tUserSign));
    }

    /**
     * 删除用户签到
     */
    //@RequiresPermissions("business:usersign:remove")
    @Log(title = "用户签到" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tUserSignService.removeByIds(Arrays.asList(ids)));
    }
}
